package com.learn.iot.ProcessorImpl;

import com.learn.iot.handler.MyInvocationHandler;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Proxy;

@Component
public class MyAopBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

//		if (beanName.equals("cityService")) {
//
//			Class<?> aClass = bean.getClass().getInterfaces()[0];
//			Class<?>[] cs = new Class<?>[]{aClass};
// 			Object o = Proxy.newProxyInstance(MyAopBeanPostProcessor.class.getClassLoader(),cs,new MyInvocationHandler(bean));
//			return o;
//
//		}
		return bean;
	}

}
